/**  形状 和 颜色
 * 原本需要 3 * 3 的进行设计
 * 可以抽离为2个单独类解偶，3 + 3 任意一类扩展
*/
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var White = /** @class */ (function () {
    function White() {
    }
    White.prototype.showColor = function (shape) {
        console.log('白色的' + shape);
    };
    return White;
}());
var Black = /** @class */ (function () {
    function Black() {
    }
    Black.prototype.showColor = function (shape) {
        console.log('黑色的' + shape);
    };
    return Black;
}());
var Red = /** @class */ (function () {
    function Red() {
    }
    Red.prototype.showColor = function (shape) {
        console.log('红色的' + shape);
    };
    return Red;
}());
var Shape = /** @class */ (function () {
    function Shape() {
    }
    Shape.prototype.setColor = function (color) {
        this.color = color;
    };
    return Shape;
}());
var Circle = /** @class */ (function (_super) {
    __extends(Circle, _super);
    function Circle() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    Circle.prototype.draw = function () {
        var _a;
        (_a = this.color) === null || _a === void 0 ? void 0 : _a.showColor('长方形');
    };
    return Circle;
}(Shape));
var Rangle = /** @class */ (function (_super) {
    __extends(Rangle, _super);
    function Rangle() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    Rangle.prototype.draw = function () {
        var _a;
        (_a = this.color) === null || _a === void 0 ? void 0 : _a.showColor('矩形');
    };
    return Rangle;
}(Shape));
(function () {
    var white = new White();
    var rangle = new Rangle();
    rangle.setColor(white);
    rangle.draw();
}());
